package com.mock.ems.utils;

import com.jfinal.plugin.activerecord.Record;
import com.mock.base.util.StringUtil;
import com.mock.ems.vo.BannerVO;

import java.util.ArrayList;
import java.util.List;

public class BannerVOUtil {

    public static List<BannerVO> getBananerVOList(Record record){

        List<BannerVO> bannerList = new ArrayList<>();

        String banners = record.get("banners");
        String urls = record.get("urls");

        if(StringUtil.isNotEmpty(banners) && StringUtil.isNotEmpty(urls)){
            String[] bannerArr = banners.split(",");
            String[] urlArr = urls.split(",");

            for(int i = 0;i <= bannerArr.length-1;i++){
                BannerVO bannerVO = new BannerVO();
                bannerVO.setBanner(bannerArr[i]);
                bannerVO.setUrl(urlArr[i]);
                bannerList.add(bannerVO);
            }
        }

        return bannerList;
    }

}
